package com.zmn.oms.admin.controller.conf.cancel.reason;


import com.zmn.common.dictionary.GlobalDict;
import com.zmn.mcc.cas.model.LoginStaff;
import com.zmn.mcc.cas.web.StaffAdminService;
import com.zmn.oms.services.interfaces.conf.cancel.OrderCancelReasonService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @author tanbiao
 * @description
 * @since 2019/10/21 18:37
 * @modifier
 **/
public class OrderCancelReasonBaseController {
    @Resource
    OrderCancelReasonService orderCancelReasonService;

    /**
     * 获取登录用户
     *
     * @return
     */
    public LoginStaff getMcStaff() {
        return StaffAdminService.currentStaff();
    }

    /**
     * 获取登录用户名
     *
     * @param
     * @return
     */
    public String getMcStaffRealName() {
        LoginStaff staff = StaffAdminService.currentStaff();
        if(Objects.nonNull(staff)){
            return staff.getRealName();
        }else {
            return "";
        }
    }

    /**
     * 附加请求参数(日志拦截需要)
     *
     * @param request
     * @param moduleId
     *            集成管理系统中定义的模块ID
     * @param aboutIds
     *            操作相关的主键ID，如skuId、categId等
     * @param aboutStatus
     *            操作相关记录的原始状态，如课程上下架状态
     */
    protected void setRequestAttributes(HttpServletRequest request, Integer moduleId, String aboutIds, Integer aboutStatus) {
    }

    protected void setRequestAttributes(HttpServletRequest request, Integer moduleId, Integer aboutId, Integer aboutStatus) {
        setRequestAttributes(request, moduleId, String.valueOf(aboutId), aboutStatus, GlobalDict.OPERATOR_TYPE_ADMIN);
    }

    /**
     * 附加请求参数(日志拦截需要)
     *
     * @param request
     * @param moduleId
     *            集成管理系统中定义的模块ID
     * @param aboutId
     *            操作相关的主键ID，如skuId、categId等
     * @param aboutStatus
     *            操作相关记录的原始状态，如课程上下架状态
     * @param operatorType
     *            操作者类型，0系统 2运营 3机构 3用户
     */
    protected void setRequestAttributes(HttpServletRequest request, Integer moduleId, String aboutId, Integer aboutStatus,
                                        Integer operatorType) {

        request.setAttribute("moduleId", moduleId == null ? 0 : moduleId);
        request.setAttribute("aboutId", aboutId);
        request.setAttribute("aboutSatus", aboutStatus == null ? 0 : aboutStatus);
        request.setAttribute("operatorType", operatorType == null ? 0 : operatorType);
    }
}
